package com.wnxy.portal.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 首页控制器，主要用于跳转，所以使用@Controller注解
 */
@Controller
@RequestMapping("/index")
public class IndexController {

    /**
     * 首页点击类别，跳转到：booklist.html
     */
    @GetMapping("/showBookList")
    public ModelAndView showBookList(Integer typeId){
        ModelAndView mv = new ModelAndView();
        mv.addObject("typeId",typeId); //Model 模型数据
        mv.setViewName("booklist"); // View 视图;跳转的页面名称
        return mv;
    }

    /**
     * 查看详情
     */
    @GetMapping("/showBookDetail")
    public ModelAndView showBookDetail(Integer bookId) {
        ModelAndView mv = new ModelAndView();
        mv.addObject("bookId",bookId);
        mv.setViewName("bookdetail");
        return mv;
    }

    /**
     * 点击下单，跳转到结算页面
     */
    @GetMapping("/calc")
    public ModelAndView toCalc(Long[] ids){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("calc");
        mv.addObject("ids",ids);
        return mv;
    }
}













